/**
 * 
 */
package fr.rcp.file.explorer.controleur;

import java.io.File;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;

import fr.rcp.file.explorer.views.Console;

/**
 * @author fred
 * 
 */
public class DeleteAction extends Action {
	private Console parent;

	public DeleteAction(Console parent, String label) {
		this.parent = parent;
		this.setText(label);
	}

	public void run() {
		IStructuredSelection selection = (IStructuredSelection) parent
				.getTableViewer().getSelection();
		File selected_file = (File) selection.getFirstElement();
		boolean response = MessageDialog.openConfirm(parent.getSite()
				.getShell(), "Confirmation",
				"Etes vous sure de vouloir supprimer ce fichier");
		if (response)
			selected_file.delete();
		parent.getTableViewer().refresh();
	}
}
